var express=require('express')
var path=require('path')
var router=require('./router.js')
var api=require('./api.js')
var bodyParser=require('body-parser')
var session = require('express-session')

var app=express()

app.use('/public/',express.static(path.join(__dirname,'./public/')))
app.use('/node_modules/',express.static(path.join(__dirname,'./node_modules/')))
app.use('/upload/',express.static(path.join(__dirname,'./upload/')))

app.engine('html', require('express-art-template'));
app.set('views',path.join(__dirname,'./views'));

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))

// parse application/json
app.use(bodyParser.json())

app.use(session({
    secret: 'notebook',
    resave: false,
    saveUninitialized: true
  }))

app.use(router)
app.use(api)

app.use(function(req,res){
  res.render('404.html')
})

app.listen(5050,function(){
    console.log('running...')
})